package killer.board.notice.controller;

import javax.annotation.Resource;

import killer.board.common.BoardVO;
import killer.board.notice.model.NoticeBoardVO;
import killer.board.notice.service.NoticeBoardService;
import killer.paging.ListVO;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

@Controller
public class NoticeBoardController {
	
	@Resource(name="noticeBoardService")
	private NoticeBoardService noticeBoardService;
	
	/**
	 * 게시판글 등록하는 메서드
	 * @param paramNbvo
	 * @return
	 */
	@RequestMapping("registerNotice.killer")
	public ModelAndView registerNotice(NoticeBoardVO paramNbvo,int nowPage)throws Exception{
		noticeBoardService.registerBoardWriting(paramNbvo);
		ListVO lvo=noticeBoardService.getBoardWritingList(nowPage);
		return new ModelAndView("board/notice/getNoticeBoardList.board","lvo",lvo);
	}
	
	/**
	 * 게시판글 쓰러 가기
	 * @return
	 */
	@RequestMapping("writeNoticeBoard.killer")
	public String writeNoticeBoard()throws Exception{
		return "board/notice/write.board";
	}
	
	/**
	 * 한페이지 게시판 글 모여주는 메서드
	 * @param nowPage
	 * @return
	 */
	@RequestMapping("getNoticeList.killer")
	public ModelAndView getNoticeList(int nowPage)throws Exception{
		ListVO lvo=noticeBoardService.getBoardWritingList(nowPage);
		return new ModelAndView("board/notice/getNoticeBoardList.board","lvo",lvo);
	}
	
	/**
	 * 한 게시물의 상세정보를 보여주는 메서드
	 * @param noticeNo
	 * @return
	 */
	@RequestMapping("getNoticeByNo.killer")
	public ModelAndView getNoticeByNo(int noticeNo)throws Exception{
		NoticeBoardVO Nbvo=(NoticeBoardVO) noticeBoardService.getBoardWritingByNo(noticeNo);
		return new ModelAndView("board/notice/getNoticeByNo.board","nBVO",Nbvo);
	}
	
	/**
	 * 게시글 업데이트 메서드
	 * @param paramNbvo
	 * @return
	 */
	public ModelAndView updateNotice(NoticeBoardVO paramNbvo)throws Exception{
		return null;
	}
	
	/**
	 * 게시글 삭제하는 메서드
	 * @param noticeNo
	 * @return
	 */
	@RequestMapping("deleteNotice.killer")
	public ModelAndView deleteNotice(int noticeNo)throws Exception{
		noticeBoardService.deleteNotice(noticeNo);
		return new ModelAndView();
	}
	
	/**
	 * 게시글 업데이트 하러 가기 전 정보 가져오기
	 * @param noticeNo
	 * @return
	 */
	@RequestMapping("getNoticeByNoForUpdate.killer")
	public ModelAndView getNoticeByNoForUpdate(int noticeNo)throws Exception{
		System.out.println("엑윽엑엑");
		NoticeBoardVO nbVO=noticeBoardService.getNoticeByNoForUpdate(noticeNo);
		return new ModelAndView("borad/notice/update.board","nbVO",nbVO);
	}
	
	
}


















